#include "../include/client.h"

int recvCmd_p(int sockfd, char *buf, int *flag,int *pathid){
    train_t train;
    bzero(&train,sizeof(train));
    recv(sockfd,&train.flag,sizeof(train.flag),0);
    recv(sockfd,&train.length,sizeof(train.length),0);
    recv(sockfd,train.data,train.length,MSG_DONTWAIT);
    *flag = train.flag;
    memcpy(buf,train.data,sizeof(train.data));
    printf("buf = %s\ntrain.data = %s\n",buf,train.data);
    //if(strlen(buf)!=0){
    //    buf[strlen(buf)] = '\0';
    //}
    ssize_t recvt = recv(sockfd,pathid,4,0);
    if(recvt ==0){
        printf("连接已终止！\n");
        return -1;
    }
    return 0;
}
